package utils

import (
	"encoding/json"
	"log"
	"os"
)

func ReadFile(filePath string) string {
	content, err := os.ReadFile(filePath)
	if err != nil {
		log.Fatalf("Error reading file: %v", err)
	}
	return string(content)
}

func JsonDecode(content string) any {
	var target any
	err := json.Unmarshal([]byte(content), &target)
	if err != nil {
		log.Fatal(err)
	}
	return target
}

func JsonEncode(data interface{}) string {
	json, err := json.MarshalIndent(data, "", "    ")
	if err != nil {
		log.Fatal(err)
	}
	return string(json)
}
